﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:markup="clr-namespace:Elysium.Markup"
                    xmlns:params="clr-namespace:Elysium.Parameters">

    <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="pack://application:,,,/Themes/SharedResources.xaml"/>
        <ResourceDictionary Source="pack://application:,,,/Themes/Buttons/ToggleButton.xaml"/>
    </ResourceDictionary.MergedDictionaries>

    <Style x:Key="ComboBoxToggleButton" TargetType="{x:Type ToggleButton}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ToggleButton}">
                    <Border Background="{markup:ThemeResource TransparentBrush}"
                            BorderBrush="{markup:ThemeResource TransparentBrush}"
                            BorderThickness="0"
                            SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}">
                        <Polygon x:Name="ArrowGlyph"
                                 Fill="{markup:ThemeResource NormalBrush}"
                                 StrokeThickness="0"
                                 Stretch="Uniform"
                                 Margin="{Binding RelativeSource={RelativeSource AncestorType={x:Type ComboBox}}, Path=(params:ComboBox.ArrowMargin), Mode=OneWay}"
                                 HorizontalAlignment="Right" VerticalAlignment="Center"
                                 Width="{Binding RelativeSource={RelativeSource AncestorType={x:Type ComboBox}}, Path=(params:ComboBox.ArrowSize), Mode=OneWay}"
                                 Height="{Binding RelativeSource={RelativeSource AncestorType={x:Type ComboBox}}, Path=(params:ComboBox.ArrowSize), Mode=OneWay}">
                            <Polygon.Points>
                                <PointCollection>
                                    <Point X="0" Y="0"/>
                                    <Point X="3" Y="4"/>
                                    <Point X="6" Y="0"/>
                                </PointCollection>
                            </Polygon.Points>
                        </Polygon>
                    </Border>
                    <ControlTemplate.Triggers>
                        <DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType={x:Type ComboBox}}, Path=IsDropDownOpen, Mode=OneWay}">
                            <Setter TargetName="ArrowGlyph" Property="Fill" Value="{markup:ThemeResource AccentBrush}"/>
                        </DataTrigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

</ResourceDictionary>